// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

using System;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Globalization;
using AjaxControlToolkit;

[assembly: System.Web.UI.WebResource("GridControl.BasicDialog.BasicDialogControlBehavior.js", "text/javascript")]

namespace GridControl
{
  
    /// <summary>
    /// Class to Extend any control into a BasicDialog element
    /// </summary>
    [Designer("GridControl.BasicDialogControlDesigner, GridControl")]
    [ClientCssResource("GridControl.yui-ext.css")]
    [ClientScriptResource("GridControl.BasicDialogControlBehavior", "GridControl.BasicDialog.BasicDialogControlBehavior.js")]
    [RequiredScript(typeof(YUI), 1)]
    [RequiredScript(typeof(ext_yui_adapter), 2)]
    [RequiredScript(typeof(YUI_ext), 3)]
    [RequiredScript(typeof(GridExtenstions), 4)]
    [TargetControlType(typeof(Control))]
    public class BasicDialogControlExtender : ExtenderControlBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:BasicDialogControlExtender"/> class.
        /// </summary>
        public BasicDialogControlExtender()
        {
            EnableClientState = true;
        }
        /// <summary>
        /// The title of the Dialog
        /// </summary>
        [ExtenderControlProperty()]
        public string Title
        {
            get
            {
                return GetPropertyValue<string>("Title", "");
            }
            set
            {
                SetPropertyValue<string>("Title", value);
            }
        }

        /// <summary>
        /// Control that will be transformed into
        /// a basic dialog
        /// </summary>
        [ExtenderControlProperty()]
        public string PopupControlID
        {
            get
            {
                return GetPropertyValue<string>("PopupControlID", "");
            }
            set
            {
                SetPropertyValue<string>("PopupControlID", value);
            }
        }
        /// <summary>
        /// If the basic dialog is closable,defaults to true
        /// </summary>
        [ExtenderControlProperty()]
        public bool Closable
        {
            get
            {
                return GetPropertyValue<bool>("Closable", true);
            }
            set
            {
                SetPropertyValue<bool>("Closable", value);
            }
        }
        /// <summary>
        /// False to remove the built-in top-right 
        /// corner collapse button (defaults to true)
        /// </summary>
        [ExtenderControlProperty()]
        public bool Collapsible
        {
            get
            {
                return GetPropertyValue<bool>("Collapsible", true);
            }
            set
            {
                SetPropertyValue<bool>("Collapsible", value);
            }
        }
        /// <summary>
        /// True to keep the dialog constrained within
        /// the visible viewport boundaries (defaults to true)
        /// </summary>
        [ExtenderControlProperty()]
        public bool Constraintoviewport
        {
            get
            {
                return GetPropertyValue<bool>("Constraintoviewport", true);
            }
            set
            {
                SetPropertyValue<bool>("Constraintoviewport", value);
            }
        }
    
        /// <summary>
        /// True to show the dialog modally, preventing user interaction 
        /// with the rest of the page (defaults to false)
        /// </summary>
        [ExtenderControlProperty()]
        public bool Modal
        {
            get
            {
                return GetPropertyValue<bool>("Modal", false);
            }
            set
            {
                SetPropertyValue<bool>("Modal", value);
            }
        }

        /// <summary>
        /// Gets or sets the minimum width of the BasicDialog.
        /// </summary>
        /// <value>The minimum width.</value>
        [ExtenderControlProperty()]
        [DefaultValue(0)]
        public int MinimumWidth
        {
            get
            {
                return GetPropertyValue("MinimumWidth", 0);
            }
            set
            {
                SetPropertyValue("MinimumWidth", value);
            }
        }

        /// <summary>
        /// Gets or sets the minimum height.
        /// </summary>
        /// <value>The minimum height.</value>
        [ExtenderControlProperty()]
        [DefaultValue(0)]
        public int MinimumHeight
        {
            get
            {
                return GetPropertyValue("MinimumHeight", 0);
            }
            set
            {
                SetPropertyValue("MinimumHeight", value);
            }
        }

      
        /// <summary>
        /// If the control is also draggable 
        /// </summary>
        [ExtenderControlProperty()]
        public bool Draggable
        {
            get
            {
                return GetPropertyValue<bool>("Draggable", false);
            }
            set
            {
                SetPropertyValue<bool>("Draggable", value);
            }
        }
     }
}
